<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <title>智能农业监控平台 - 后台管理</title>
  <link rel="stylesheet" href="css/dashboard.css" />
</head>
<body>
  <header>
    <h1>智能农业监控平台 - 后台管理</h1>
  </header>

  <main>
    <div class="card">
      <h3>传感器配置</h3>
      <form id="sensorConfig">
        <label>温度报警阈值：<input type="number" value="30" />°C</label>
        <label>湿度报警阈值：<input type="number" value="70" />%</label>
        <button type="submit">保存设置</button>
      </form>
    </div>

    <div class="card">
      <h3>用户管理</h3>
      <table border="1" width="100%">
        <thead>
          <tr>
            <th>用户名</th>
            <th>角色</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>farmer1</td>
            <td>农户</td>
            <td><button onclick="deleteUser(this)">删除</button></td>
          </tr>
          <tr>
            <td>tech_admin</td>
            <td>管理员</td>
            <td><button onclick="deleteUser(this)">删除</button></td>
          </tr>
        </tbody>
      </table>
    </div>
  </main>

  <script>
    document.getElementById('sensorConfig').addEventListener('submit', function (e) {
      e.preventDefault();
      // 实际应与后端交互保存设置
      alert('设置已保存');
    });

    function deleteUser(button) {
      if (confirm('确定要删除该用户吗？')) {
        const row = button.parentNode.parentNode;
        row.parentNode.removeChild(row);
      }
    }
  </script>
</body>
</html>